#include <iostream>
/***
 * 多级指针
 */

using namespace std;

//多级指针

int main()
{
    int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    int b[3][4] =
            {
                    11, 22, 33,
                    44, 55, 66,
                    77, 88, 99,
                    111, 222, 333
            };

    int *p1 = nullptr, *p2 = nullptr, **p3 = nullptr;

    p1 = a;     // p1指向a数组
    p3 = &p1;   // p3指向p1

    for (int i = 0; i < 10; ++i)
    {
        cout << *(*p3 + i) << " ";  // 输出: 0 1 2 3 4 5 6 7 8 9
    }

    cout << endl;

    for (p1 = a; p1 - a < 10; ++p1)
    {
        p3 = &p1;
        cout << ** p3 << " ";       // 输出: 0 1 2 3 4 5 6 7 8 9
    }

    cout << endl;

    for (int i = 0; i < 3; ++i)
    {
        p2 = b[i];
        p3 = &p2;
        for (int j = 0; j < 4; ++j)
        {
            cout << *(*p3 + j) << " ";  // 输出：11 22 33 44 55 66 77 88 99 111 222 333
        }
    }

    return 0;
}